
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region RoleDAL
	public class RoleDAL : DBContext
	{
		public List<Role> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RolesSelectAll");
            return GetEntityList<Role>(cmd);
        }

        public Role GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RoleSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<Role>(cmd);
        }

		public List<Role> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RoleSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<Role>(cmd);
        } 
		
        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RoleDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public Role UpdateById(
		Guid paramRoleID,

		string paramName,

		int paramStatus,

		string paramUpdatedBy,
		DateTime paramUpdateOn
			)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RoleUpdate");
			cmd.AddParameter("@RoleID", paramRoleID);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Status", paramStatus);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            cmd.AddParameter("@UpdatedOn", DateTime.Now);
            return GetSingleEntity<Role>(cmd);
        }
		
	}
	#endregion
}
